var h = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
function encodedata(t) {
	var a, i, e, s, n, l = "", c = "", o = "", r = 0;
	do {
		e = (a = t.charCodeAt(r++)) >> 2,
		s = (3 & a) << 4 | (i = t.charCodeAt(r++)) >> 4,
		n = (15 & i) << 2 | (c = t.charCodeAt(r++)) >> 6,
		o = 63 & c,
		isNaN(i) ? n = o = 64 : isNaN(c) && (o = 64),
		l = l + h.charAt(e) + h.charAt(s) + h.charAt(n) + h.charAt(o),
		a = i = c = "",
		e = s = n = o = ""
	} while (r < t.length);
	return l
}
// console.log(encodedata('122382ugwegugh'));

// =====================
window = {}
const JSEncrypt = require('jsencrypt');

function jsEncRsa(str){
	// 设置公钥
	var publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCCsYUGHMhjSzdMqn9JzPfKs9JbxXTPtHofTv7reV0HrEz4brnE6ZJpNn5s934KO3L4QDF7ELHysIiounhhpF1bewW9jKdcpZA5M1CkGHKcwpLA2liaqOlt/0Mf3ui9jxR9AHxUMFVGfJ6Q4+cEmDBUAEOXlxqk4ZjGpubwGNk9XQIDAQAB"
	var encryptor = new JSEncrypt();
	encryptor.setPublicKey(publicKey);
	// 加密数据
	var encrypted = encryptor.encrypt('Hello, World!'); // 加密字符串数据
	return encrypted;
}
// console.log(jsEncRsa('123'))